package com.woniuxy.project115.kaer.mall.controller;


import com.woniuxy.project115.kaer.commons.util.JwtUtil;
import com.woniuxy.project115.kaer.commons.util.Result;
import com.woniuxy.project115.kaer.mall.service.OrderOfProductService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * <p>
 * 订单商品数据表 前端控制器
 * </p>
 *
 * @author lyc
 * @since 2025年02月17日
 */
@RestController
@RequestMapping("/orderOfProduct")
@Api(tags = "订单商品接口")
public class OrderOfProductController {
    @Resource
    private OrderOfProductService orderOfProductService;
    //添加商品到购物车
    @PostMapping("addToCart")
    @ApiOperation("添加商品到购物车")
    public Result addToCart(Integer productId, Integer number, @RequestHeader("token")String token) throws Exception {
        Integer userId = JwtUtil.getUserId(token);
        orderOfProductService.addToCart(productId, number, userId);
        return Result.succeed("添加到购物车成功");
    }
//    public Result addToCart(Integer productId, Integer number, Integer userId) throws Exception {
//        orderOfProductService.addToCart(productId, number, userId);
//        return Result.succeed("添加到购物车成功");
//    }
}

